import 'package:flutter/material.dart';
import 'package:hello_flutter/util/RouteUtils.dart';
import 'dio/DioUploadTest.dart';
import 'dio/DioDownloadTest.dart';

///
/// 第三方插件DIO测试代码
/// dio是一个强大的Dart Http请求库，支持Restful API、FormData、拦截器、请求取消、Cookie管理、文件上传/下载、超时等...
/// https://github.com/flutterchina/dio
///
class TestDio extends StatefulWidget {
  @override
  _TestDioState createState() => _TestDioState();
}

class _TestDioState extends State<TestDio> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('第三方插件DIO相关Demo'),
      ),
      body: ListView(
        children: <Widget>[
          ListTile(
            leading: Icon(Icons.list),
            title: Text("文件上传Demo"),
            onTap: () {
              showDialog<Null>(
                context: context, //BuildContext对象
                barrierDismissible: false,
                builder: (BuildContext context) {
                  return new DioUploadTest();
                },
              );
            },
          ),
          ListTile(
            leading: Icon(Icons.list),
            title: Text("文件下载Demo"),
            onTap: () {
              RouteUtils.route2Page(context, DioDownloadTest());
            },
          ),
        ],
      ),
    );
  }
}